package project02.dao;

import java.util.logging.Logger;
import javax.jdo.PersistenceManager;
import org.slim3.jdo.SelectQuery;
import project02.model.UserInfo;
import project02.meta.UserInfoMeta;
import org.slim3.jdo.GenericDao;

public class UserInfoDao extends GenericDao<UserInfo> {

    private static final UserInfoMeta m = new UserInfoMeta();

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(UserInfoDao.class.getName());

    public UserInfoDao() {
        super(UserInfo.class);
    }


    public UserInfoDao(PersistenceManager pm) {
        super(UserInfo.class, pm);
    }

    @Override
    protected SelectQuery<UserInfo> from() {
        return new SelectQuery<UserInfo>(pm, m.getModelClass());
    }

    public UserInfo findByimodeId(String imodeId) {
        UserInfo result = new UserInfo();
        try {
            result = from().where(m.userAccount.eq(imodeId)).getSingleResult();
        } catch (Exception e) {
            result = null;
        }
        return result;
    }

    public UserInfo findByUserId(String userId) {

        UserInfo result = new UserInfo();
        try {
            result = from().where(m.userId.eq(userId)).getSingleResult();
        } catch (Exception e) {
            result = null;
        }

        return result;
    }

}
